﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="coupons_allotment_list.aspx.cs" Inherits="Donal.Xms.Web.qianyi.common.coupons_allotment_list" ValidateRequest="false" %>

<%@ Import Namespace="Donal.Xms.Common" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>分配管理</title>
    <link rel="stylesheet" type="text/css" href="../../scripts/artdialog/ui-dialog.css" />
    <link rel="stylesheet" type="text/css" href="../../css/pagination.css" />
    <link rel="stylesheet" type="text/css" href="../skin/icon/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../skin/default/style.css" />
    <script type="text/javascript" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../scripts/datepicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../scripts/artdialog/dialog-plus-min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/laymain.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
    <script>
        $(function () {
            $(".toolbar").ruleLayoutToolbar();

            $("#btnExport").click(function () {
                dialog({
                    title: "优惠券分配导出",
                    content: "您确定要将分配优惠券记录导出吗？",
                    okValue: "确定",
                    ok: function () {

                        var wd = top.dialog({
                            id: 'DialogWait',
                            title: '请稍后……'
                        }).showModal();

                        $.ajax({
                            type: "post",
                            url: "/tools/ExportExcel.ashx?action=exp_coupons_allotment_data_" + new Date().getTime(),
                            data: {
                                keywords:'<%= keywords%>',
                                status:'<%= status%>',
                                isUsed: '<%= isUsed%>',
                                couponsType: '<%= couponsType%>',
                                start_time: '<%= start_time%>',
                                end_time: '<%= end_time%>',
                                ot: '<%= ot%>'
                            },
                            dataType: "json",
                            success: function (data) {

                                wd.close().remove();

                                if (data.status == 0) {
                                    top.dialog({
                                        id: 'DialogStatus',
                                        title: '提示',
                                        content: data.msg,
                                        okValue: '确定',
                                        ok: function () { }
                                    }).showModal();

                                } else {
                                    downLink(data.msg);
                                    return true;
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                top.dialog({
                                    title: '提示',
                                    content: '尝试发送失败，错误信息：' + errorThrown,
                                    okValue: '确定',
                                    ok: function () { }
                                }).showModal();
                            }

                        });
                    },
                    cancelValue: "取消",
                    cancel: function () { }
                }).showModal();
            });

            //链接下载
            function downLink(linkurl) {
                window.location.href = linkurl;
                return false;
            }


        });

        function showDialog(userId, couponId, allotmentId) {

            var companyDialog = top.dialog({
                id: 'couponsDialogId',
                title: "使用记录",
                url: 'dialog/dialog_coupon_used_logs.aspx?user_id=' + userId + '&coupon_id=' + couponId + '&allotment_id=' + allotmentId,
                width: 1000,
                height: 700,
                onclose: function () {
                    window.location.reload();
                }
            }).showModal();
        }

        function showWait() {
            top.dialog({
                title: "请稍等……"
            }).showModal();
        }
    </script>
</head>

<body class="mainbody">
    <form id="form1" runat="server">
        <!--导航栏-->
        <div class="location">
            <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
            <a href="../center.aspx" class="home"><i class="iconfont icon-home"></i><span>首页</span></a>
            <i class="arrow iconfont icon-arrow-right"></i>
            <span>分配管理</span>
        </div>
        <!--/导航栏-->

        <!--工具栏-->
        <div id="floatHead" class="toolbar-wrap">
            <div class="toolbar">
                <div class="box-wrap">
                    <a class="menu-btn"><i class="iconfont icon-more"></i></a>
                    <div class="l-list">
                        <ul class="icon-list">
                            <li>
                                <a style="cursor: pointer" id="btnExport"><i class="iconfont icon-exl"></i><span>导出</span></a></li>
                            <li><a href="allotment_company_list.aspx?action=<%=DTEnums.ActionEnum.Add %>"><i class="iconfont icon-close"></i><span>分配</span></a></li>
                            <li><a href="javascript:;" onclick="checkAll(this);"><i class="iconfont icon-check"></i><span>全选</span></a></li>
                            <li>
                                <asp:LinkButton ID="btnLocked" runat="server" OnClientClick="return ExePostBack('btnLocked','您确定要删除选中的优惠券吗？');" OnClick="btnLocked_Click"><i class="iconfont icon-wrong"></i><span>删除</span></asp:LinkButton></li>
                            <li>
                                <asp:LinkButton ID="btnBatAllotment" runat="server" OnClientClick="showWait();" OnClick="btnBatAllotment_Click"><i class="iconfont icon-wrong"></i><span>批量分配</span></asp:LinkButton></li>
                        </ul>
                        <div class="menu-list">
                            <div class="rule-single-select">
                                <asp:DropDownList ID="ddlIsUsed" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlIsUsed_SelectedIndexChanged">
                                    <asp:ListItem Value="" Selected="True">使用状态</asp:ListItem>
                                    <asp:ListItem Value="u">已使用</asp:ListItem>
                                    <asp:ListItem Value="n">未使用</asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="rule-single-select">
                                <asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged">
                                    <asp:ListItem Value="" Selected="True">是否关联</asp:ListItem>
                                    <asp:ListItem Value="z">有关联</asp:ListItem>
                                    <asp:ListItem Value="j">无关联</asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="rule-single-select">
                                <asp:DropDownList ID="ddlCouponsType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlCouponsType_SelectedIndexChanged">
                                    <asp:ListItem Value="" Selected="True">是否叠加</asp:ListItem>
                                    <asp:ListItem Value="d">可叠加</asp:ListItem>
                                    <asp:ListItem Value="m">不可叠加</asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="rule-single-select">
                                <asp:DropDownList ID="ddlOvertime" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlOvertime_SelectedIndexChanged">
                                    <asp:ListItem Value="" Selected="True">到期状态</asp:ListItem>
                                    <asp:ListItem Value="x">已到期</asp:ListItem>
                                    <asp:ListItem Value="y">未到期</asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <asp:TextBox ID="txtStartTime" runat="server" CssClass="input allotment-date-input" Width="100" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="分配时间"></asp:TextBox>
                            -
                            <asp:TextBox ID="txtEndTime" runat="server" CssClass="input allotment-date-input" Width="100" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="分配时间"></asp:TextBox>
                            <style>
                                .all-date-input {
                                    width: 100px;
                                }
                            </style>
                        </div>
                    </div>
                    <div class="r-list">
                        <asp:TextBox ID="txtKeywords" runat="server" CssClass="keyword" />
                        <asp:LinkButton ID="lbtnSearch" runat="server" CssClass="btn-search" OnClick="btnSearch_Click"><i class="iconfont icon-search"></i></asp:LinkButton>
                    </div>
                </div>
            </div>
        </div>
        <!--/工具栏-->

        <!--列表-->
        <div class="table-container">
            <asp:Repeater ID="rptList" runat="server">
                <HeaderTemplate>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
                        <tr>
                            <th width="5%">选择</th>
                            <th width="5%">会员编码</th>
                            <th width="10%">会员名称</th>
                            <th width="10%">优惠券名称</th>
                            <th width="10%">描述</th>
                            <th width="5%">是否关联</th>
                            <th width="5%">是否叠加</th>
                            <th width="8%">分配时间</th>
                            <th width="8%">到期时间</th>
                            <th width="8%">到期状态</th>
                            <th width="5%">使用状态</th>
                            <th width="8%">使用时间</th>
                            <th width="8%">订单号</th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td align="center">
                            <asp:CheckBox ID="chkId" CssClass="checkall" runat="server" />
                            <asp:HiddenField ID="hidId" Value='<%#Eval("id")%>' runat="server" />
                            <asp:HiddenField ID="hidUserName" Value='<%#GetCompanyName(Eval("user_id").ToString(),"company")%>' runat="server" />
                            <asp:HiddenField ID="hidContents" Value='<%#Eval("contents")%>' runat="server" />
                        </td>
                        <td align="center"><%#GetCompanyName(Eval("user_id").ToString(),"erpCode") %></td>
                        <td align="center"><%#GetCompanyName(Eval("user_id").ToString(),"company")%></td>
                        <td align="center">
                            <a href="coupons_allotment_edit.aspx?action=<%#DTEnums.ActionEnum.View %>&id=<%#Eval("id")%>">
                                <%#Eval("title")%>
                            </a>
                        </td>
                        <td align="center">
                            <%#Eval("contents")%>                            
                        </td>
                        <td align="center"><%#Eval("coupon_ids").ToString()==""?"无关联":"有关联"%></td>
                        <td align="center"><%#Eval("superposition").ToString()=="1"?"可叠加":"不可叠加"%></td>
                        <td align="center"><%#DateTime.Parse(Eval("allotment_time").ToString()).ToString("yyyy-MM-dd HH:mm:ss")%></td>
                        <td align="center"><%# Eval("over_time").ToString()!=""?DateTime.Parse(Eval("over_time").ToString()).ToString("yyyy-MM-dd HH:mm:ss"):"---"%></td>
                        <td align="center"><%#GetOverStatus(Eval("over_time").ToString())%></td>
                        <td align="center"><%#Eval("order_no").ToString()==""?"未用":"已用"%></td>
                        <td align="center"><%#new Donal.Xms.BLL.orders().GetValue(Eval("order_no").ToString(), "add_time")%></td>
                        <td align="center"><%#Eval("order_no")%></td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    <%#rptList.Items.Count == 0 ? "<tr><td align='center' colspan='12'>暂无记录</td></tr>" : ""%>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
        </div>
        <!--/列表-->

        <!--内容底部-->
        <div class="line20"></div>
        <div class="pagelist">
            <div class="l-btns">
                <span>显示</span><asp:TextBox ID="txtPageNum" runat="server" CssClass="pagenum" onkeydown="return checkNumber(event);"
                    OnTextChanged="txtPageNum_TextChanged" AutoPostBack="True"></asp:TextBox><span>条/页</span>
            </div>
            <div id="PageContent" runat="server" class="default"></div>
        </div>
        <!--/内容底部-->

    </form>
</body>
</html>

